package com.ruoyi.insert.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.profession.domain.EducationTraining;
import com.ruoyi.profession.service.IEducationTrainingService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 进修信息Controller
 * 
 * @author ruoyi
 * @date 2024-05-31
 */
@RestController
@RequestMapping("/insert/educationTraining")
public class IEducationTrainingController extends BaseController
{
    @Autowired
    private IEducationTrainingService educationTrainingService;

    /**
     * 查询进修信息列表
     */
    @PreAuthorize("@ss.hasPermi('profession:educationTraining:list')")
    @GetMapping("/list")
    public TableDataInfo list(EducationTraining educationTraining)
    {
        startPage();
        List<EducationTraining> list = educationTrainingService.selectEducationTrainingList(educationTraining);
        return getDataTable(list);
    }

    /**
     * 导出进修信息列表
     */
    @PreAuthorize("@ss.hasPermi('profession:educationTraining:export')")
    @Log(title = "进修信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EducationTraining educationTraining)
    {
        List<EducationTraining> list = educationTrainingService.selectEducationTrainingList(educationTraining);
        ExcelUtil<EducationTraining> util = new ExcelUtil<EducationTraining>(EducationTraining.class);
        util.exportExcel(response, list, "进修信息数据");
    }

    /**
     * 获取进修信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('profession:educationTraining:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(educationTrainingService.selectEducationTrainingById(id));
    }

    /**
     * 新增进修信息
     */
    @PreAuthorize("@ss.hasPermi('profession:educationTraining:add')")
    @Log(title = "进修信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EducationTraining educationTraining)
    {
        return toAjax(educationTrainingService.insertEducationTraining(educationTraining));
    }

    /**
     * 修改进修信息
     */
    @PreAuthorize("@ss.hasPermi('profession:educationTraining:edit')")
    @Log(title = "进修信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EducationTraining educationTraining)
    {
        return toAjax(educationTrainingService.updateEducationTraining(educationTraining));
    }

    /**
     * 删除进修信息
     */
    @PreAuthorize("@ss.hasPermi('profession:educationTraining:remove')")
    @Log(title = "进修信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(educationTrainingService.deleteEducationTrainingByIds(ids));
    }
}
